使用Standby Preempt和Standby Track命令

您所在的位置:网站首页 goes down翻译 使用Standby Preempt和Standby Track命令

使用Standby Preempt和Standby Track命令

2023-10-09 20:53| 来源: 网络整理| 查看: 265

简介

本文档介绍standby preempt和standby track命令如何协同工作以及如何使用。

先决条件 要求

本文档没有任何特定的要求。

使用的组件

本文档中的信息基于以下软件版本:

运行Cisco IOS®软件版本12.2(10b)的路由器

本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您的网络处于活动状态,请确保您了解所有命令的潜在影响。

规则

有关文档规则的详细信息,请参阅Cisco技术提示规则。

背景信息

standby preemptcommand使具有最高优先级的热备份路由器协议(HSRP)路由器立即成为活动路由器。优先级的确定首先取决于所配置的优先级值,然后取决于 IP 地址。在每种情形下,都是更高的值具有更高的优先级。当一个更高优先级的路由器优先于一个较低优先级的路由器时,该路由器会发送一条 Coup 消息。当优先级较低的活动路由器从一个更高优先级的活动路由器接收到 Coup 消息或 Hello 消息时,该路由器会更改为对话状态,并发送放弃消息。

standby trackcommand允许您在路由器上指定另一个接口,供HSRP进程进行监控,以便更改给定组的HSRP优先级。如果指定接口的线路协议关闭,则会降低 HSRP 优先级。这意味着,如果另一台优先级较高的HSRP路由器启用了备用抢占,则该路由器可以成为活动路由器。

下图显示了一个将standby preemptcommand与standby trackcommand结合使用的示例。

备用抢占和备用跟踪配置

配置示例

在网络图中,HSRP 是以这种方式配置的:

R1是活动路由器,跟踪R1 Serial 0接口状态。当R1是活动路由器时,从主机(主机1、主机2、主机3)到服务器的所有流量都通过R1路由。

R2是备用路由器并跟踪R2 Serial 1接口状态。

如果R1 Serial 0接口关闭,则R1 HSRP优先级会减少10。此时,R2 HSRP优先级高于R1,R2将接管活动路由器的角色。

当R2成为活动路由器时,从主机到服务器的所有流量都会通过R2路由。

注:主机1、2和3的默认网关配置了HSRP虚拟IP地址(本例中为172.16.6.100)。在路由器上配置一个路由协议(例如 RIP),可实现主机和服务器之间的连接。

这是每台路由器的配置:

路由器 1 (Cisco 2503) interface Ethernet0 ip address 172.16.6.5 255.255.255.0 !--- Assigns an IP address to the interface. no ip redirects standby 1 ip 172.16.6.100 !--- Assigns a standby group and standby IP address standby 1 priority 105 !--- Assign a priority (105 in this case) to the router interface (e0) !--- for a particular group number (1). The default is 100. standby 1 preempt !--- Allows the router to become the active router when the priority !--- is higher than all other HSRP-configured routers in the hot standby group. !--- If you do not use the standby preempt command in the configuration !--- for a router, that router does not become the active router, even if !--- the priority is higher than all other routers. standby 1 track Serial0 !--- Indicates that HSRP tracks Serial0 interface. !--- The interface priority can also be configured, which indicates the !--- amount by which the router priority decreases when !--- the interface goes down. The default is 10. interface Serial0 ip address 172.16.2.5 255.255.255.0 路由器 2 (Cisco 2503) interface Ethernet0 ip address 172.16.6.6 255.255.255.0 !--- Assigns an IP address to the interface. no ip redirects standby 1 ip !--- Indicates the hot standby group. Here the IP address of the virtual router !--- is not configured. See the note after this table. standby 1 preempt !--- Allows the router to become the active router when the priority !--- is higher than all other HSRP-configured routers in the hot standby group. !--- If you do not use the standby preempt command in the configuration !--- for a router, that router does not become the active router, even if !--- the priority is higher than all other routers. standby 1 track Serial1 !--- Indicates that HSRP tracks Serial1 interface. !--- The interface priority can also be configured, which indicates the !--- amount by which the router priority decreases when !--- the interface goes down. The default is 10. !--- The priority is also not configured and hence the default !--- priority value of 100 is applied. interface Serial1 ip address 172.16.7.6 255.255.255.0

注意:R2未配置备用IP地址。这样做是特意为了显示出这是有效配置。当 R1 和 R2 交换 HSRP hello 时,R2 从 R1 获知备用 IP 地址。为R2配置备用IP地址(在R1上配置相同的备用地址)也是有效配置。

R1#show standby Ethernet0 - Group 1 Local state is Active, priority 105, may preempt Hellotime 3 sec, holdtime 10 sec Next hello sent in 1.458 Virtual IP address is 172.16.6.100 configured Active router is local Standby router is 172.16.6.6 expires in 8.428 Virtual mac address is 0000.0c07.ac01 2 state changes, last state change 02:09:49 IP redundancy name is "hsrp-Et0-1" (default) Priority tracking 1 interface, 1 up: Interface Decrement State Serial0 10 Up R2#show standby Ethernet0 - Group 1 Local state is Standby, priority 100, may preempt Hellotime 3 sec, holdtime 10 sec Next hello sent in 1.814 Virtual IP address is 172.16.6.100 Active router is 172.16.6.5, priority 105 expires in 9.896 Standby router is local 3 state changes, last state change 00:10:21 IP redundancy name is "hsrp-Et0-1" (default) Priority tracking 1 interface, 1 up: Interface Decrement State Serial1 10 Up

虽然 R2 没有配置 HSRP 优先级,但是输出显示 R2 优先级为 HSRP 默认值,即 100。两台路由器的输出都表明路由器跟踪串行接口的状态。R1 的状态是活动的,而 R2 的状态为备用。最后,两个路由器均使用 standby preempt 命令配置。

如果 R1 的 serial 0 接口断开,将会如何?show standby 命令的输出如下所示:

R1#show standby Ethernet0 - Group 1 Local state is Standby, priority 95 (confgd 105), may preempt Hellotime 3 sec, holdtime 10 sec Next hello sent in 2.670 Virtual IP address is 172.16.6.100 configured Active router is 172.16.6.6, priority 100 expires in 8.596 Standby router is local 4 state changes, last state change 00:01:45 IP redundancy name is "hsrp-Et0-1" (default) Priority tracking 1 interface, 0 up: Interface Decrement State Serial0 10 Down R2#show standby Ethernet0 - Group 1 Local state is Active, priority 100, may preempt Hellotime 3 sec, holdtime 10 sec Next hello sent in 0.810 Virtual IP address is 172.16.6.100 Active router is local Standby router is 172.16.6.5 expires in 9.028 Virtual mac address is 0000.0c07.ac01 4 state changes, last state change 00:01:38 IP redundancy name is "hsrp-Et0-1" (default) Priority tracking 1 interface, 1 up: Interface Decrement State Serial1 10 Up

请注意,在输出中,R1的HSRP优先级降低了10到95。此更改使 R2 的优先级(其值为 100)高于 R1。当R2的优先级变高时,R2被配置为standby preempt,因此R2成为活动路由器,R1成为备用路由器。此时,如果 R1 serial 0 接口恢复,则 R1 优先级会重新变为 105。在这种情况下,R1 会抢占优先并再次成为 HSRP 活动路由器。

注意:如果R2上未配置standby preempt,R2不会向R1发送Coup消息,这会导致R2变为活动状态。这样的话,R1 将仍为活动路由器。

例如,请看以下配置:

standby priority 120 standby track serial 0 standby track serial 1

使用 standby priority命令配置HSRP优先级120,并配置HSRP以跟踪两个接口(Serial0和Serial1)的状态。由于 standby track 命令中指定递减值,则当所跟踪的接口断开时,HSRP 优先级以默认值 10 递减。最初,两个接口均启用,并且接口的 HSRP 优先级为 120,正如 show standby 命令输出中所示:

R1#show standby Ethernet0 - Group 1 Local state is Active, priority 120, may preempt Hellotime 3 sec, holdtime 10 sec Next hello sent in 1.034 Virtual IP address is 10.0.0.5 configured Active router is local Standby router is unknown Virtual mac address is 0000.0c07.ac01 2 state changes, last state change 00:00:04 IP redundancy name is "hsrp-Et0-1" (default) Priority tracking 2 interfaces, 2 up: Interface Decrement State Serial0 10 Up Serial1 10 Up

此时,接口 Serial 0 断开。

R1# 1w0d: %LINK-3-UPDOWN: Interface Serial0, changed state to down 1w0d: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to down R1#

这会将HSRP优先级从120减少10到值110。可以使用 show standby 命令来验证:

R1#show standby Ethernet0 - Group 1 Local state is Active, priority 110 (confgd 120), may preempt Hellotime 3 sec, holdtime 10 sec Next hello sent in 2.544 Virtual IP address is 10.0.0.5 configured Active router is local Standby router is unknown Virtual mac address is 0000.0c07.ac01 2 state changes, last state change 00:00:48 IP redundancy name is "hsrp-Et0-1" (default) Priority tracking 2 interfaces, 1 up: Interface Decrement State Serial0 10 Down (line protocol down) Serial1 10 Up

接下来,第二个所跟踪的接口 Serial 1 断开:

R1# 1w0d: %LINK-3-UPDOWN: Interface Serial1, changed state to down 1w0d: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1, changed state to down R1#

这再次将HSRP优先级从110降低到100。可以使用 show standby 命令来验证:

R1#show standby Ethernet0 - Group 1 Local state is Active, priority 100 (confgd 120), may preempt Hellotime 3 sec, holdtime 10 sec Next hello sent in 1.846 Virtual IP address is 10.0.0.5 configured Active router is local Standby router is unknown Virtual mac address is 0000.0c07.ac01 2 state changes, last state change 00:01:06 IP redundancy name is "hsrp-Et0-1" (default) Priority tracking 2 interfaces, 0 up: Interface Decrement State Serial0 10 Down (line protocol down) Serial1 10 Down (line protocol down)

当任何一个所跟踪的串行接口(serial 0 或 serial 1)断开时,均导致优先级变为 110。当这两个所跟踪的串行接口(serial 0 和 serial 1)都断开时,导致优先级变为 100。

相关信息 HSRP 支持页 技术支持和文档 - Cisco Systems


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3